<?php

namespace App\Command\Cron;

use App\Utils\Enum\CommandEnum;
use MyBuilder\Bundle\CronosBundle\Annotation\Cron;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class DefaultCommand
 * @package App\Command\Crontab
 * @Cron(minute="10", hour="1", noLogs=true, server="web")
 */
class RevokeAllInvalidTokensCommand extends Command {
    protected static $defaultName = 'cron:revoke-all-invalid-tokens';

    protected function configure () {
        $this->setDescription('每天凌晨一点十分清除无效refresh token');
    }

    protected function execute (InputInterface $input, OutputInterface $output) {
        $application = $this->getApplication();
        $command = $application->find('gesdinet:jwt:clear');
        $arguments = [
            'command' => 'gesdinet:jwt:clear',
        ];
        $greetInput = new ArrayInput($arguments);
        $bufferedOutput = new BufferedOutput();
        $command->run($greetInput, $bufferedOutput);
        return CommandEnum::SUCCESS;
    }
}